<?php
GLOBAL $CFG;
require_once('../../../config.php');

require_once($CFG->libdir . '/formslib.php');
require_once($CFG->dirroot . '/local/blackboxsurvey/lib.php');
require_once($CFG->dirroot . "/local/blackboxsurvey/forms.php");

//yeu cau login,sau khi login tu dong chuyen sang trang chu
global $USER;
if ($USER->id == null){
    $SESSION->homepage = true;
    require_login($SITE);
}
if($SESSION->homepage){
    $SESSION->homepage = null;
    redirect( $CFG->wwwroot);
}

//class
require_once($CFG->dirroot . "/local/blackboxsurvey/class/questionaire.php");
$path = $CFG->wwwroot.'/local/blackboxsurvey/lecturer/manage_questionaire.php';
$path_image = $CFG->wwwroot .'/local/blackboxsurvey/image/';

//Them thanh menu ngang ung voi trang trong duong link
navigation_node::override_active_url(new moodle_url($path, array('param'=>'value')));

/* Chuan bi trang web can hien thi */	
$url = new moodle_url($path);
$PAGE->set_url($url);
$PAGE->set_title('Questionnaire Management');
$PAGE->set_heading('Questionnaire Management');
$PAGE->set_pagelayout('standard');

echo $OUTPUT->header();

$str = '<div id="Filter" >'.get_string('searchsurvey', 'local_blackboxsurvey').': <input type=text id="FilterTextBox" name="FilterTextBox" size="40"/><img onclick="clear_filter_edit_only();" style="cursor:pointer;" src="'.$path_image.'clear.jpg"/></div><br>';
//tao danh sach cau hoi
$temp = new b_questionaire();
global $USER;
$str .= $temp->search_qustionnaire_results($USER->id);

/* Viet doan code cua ban o day */
$mform = new form_questionaire_management(null, array('str'=>$str));
$mform->display();
echo "<script type='text/javascript'>filter();survey_questionaire_result();</script>"; 
/*------Ket thuc doan code cua ban-------*/
echo $OUTPUT->footer();
